package edu.purdue.cs505;

public class DelayedMessage implements Comparable<DelayedMessage>
{
  public Message message;
  public long deliveryTime;
  
  public DelayedMessage(Message message, long deliveryTime) {
    this.message = message;
    this.deliveryTime = deliveryTime;
  }
  
  @Override
  public int compareTo(DelayedMessage o)
  {
    return (int) (deliveryTime - o.deliveryTime);
  }
  
  @Override
  public boolean equals(Object obj)
  {
    DelayedMessage other = (DelayedMessage)obj;
    return message.equals(other.message) && deliveryTime == other.deliveryTime;
  }
  
  @Override
  public int hashCode()
  {
    return message.hashCode() + (int)deliveryTime;
  }
  
  public String toString() {
    return deliveryTime + " " + message.toString();
  }
}
